<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="cake.db.MySqlDb"%>
<%@page import="java.sql.ResultSet"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>cake comments</title>
		<link rel="stylesheet" href="styles/style.css" type="text/css" />
		<script src="scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
		<script src="scripts/jquery.select.js" type="text/javascript"></script>
		<script src="scripts/tools.js" type="text/javascript"></script>
		<script src="scripts/script.js" type="text/javascript"></script>
	</head>
	<body>
		<div id="container">
			<div id="header">
				<%@include file="header.jsp" %>
			</div>
			<div id="content">
				<div style="margin-left: 35px;">
					<div>
						Location：
						<a href="index.jsp">Home</a> &gt;<a href="cakes.jsp">Reservation</a> &gt; Comments
					</div>
					<table border="1" cellpadding="0" cellspacing="0" style="margin-left:100px;border-collapse: collapse;" bordercolor="#CCCCCC">
								<tr style="background-color:#FCF2E4;">
									<td width="30"> 
										Index 
									</td>
									<td width="450">
										Content
									</td>
									<td width="150">
										User
									</td>
									<td width="140">
										Time
									</td>
								</tr>
					<%
						String cake=request.getParameter("cake");
								
						if(cake!=null && !cake.equals(""))
						{
							String sql="select user.username as username,comment.* from comment left outer join orderdetail on comment.orderid=orderdetail.orderid "
								+" left outer join cake on orderdetail.cakeid=cake.id "
								+" left outer join user on comment.userid=user.id where cake.id="+cake;
								
							MySqlDb db = new MySqlDb();
							ResultSet rs = db.query(sql);
							int index=1;
							while (rs.next()) {
									%>
									<tr>
										<td><%=index %></td>
										<td><%=rs.getString("content") %></td>
										<td>
										<%=rs.getString("username") %></td>
										<td><%=rs.getString("occurTime") %></td>
									</tr>
									<%
							index++;
							}
						}
					 %>
					 
					 </table>
				</div>
				<div id="categorys" style="clear:both;">
					<%@include file="footer.jsp" %>
				</div>
			</div>
		</div>
	</body>
</html>
